﻿/// <reference path="../../js/public.js" />
$$(function () {
    startCountDown();
    $$("#btn-send-code").on("click", function () {
        startCountDown();
        sendCheckCode();
    });

    $$("#btn-check-mobile").on("click", validCheckCode);
});

//启动倒计时
function startCountDown() {
    var isEnd = true;

    if (isEnd === true) {
        var cd = 5;
        var clock = $$("#btn-clock");
        var btn = $$("#btn-send-code");
        btn.hide();
        clock.html("重新发送(" + cd + "s)").show();

        new MG.SecoudCountDown(cd, function (h, m, s, container, seconds) {
            clock.html("重新发送(" + seconds + "s)");
        }, function () {
            clock.hide();
            btn.show();
            isEnd = true;
        });
    }
}

//发送短信验证
function sendCheckCode() {
    $.toast("验证码短信已发送！");
}

//校验验证码
function validCheckCode() {
    var checkCode = $$.trim($$("#txt-checkcode").val());
    if (checkCode.length == 0) {
        $.toast("请输入短信验证码！");
        return;
    }

    //进入下一步
    $.router.load(getNextUrl(), true);
}

function getNextUrl() {
    return decodeURIComponent(new MG.UrlOper().Get("goto"));
}